package com.china.produce.cglib;

import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;
import java.lang.reflect.Method;

/**
 * @ClassName
 * @Author niujie
 * @Version
 * @Description
 * @CreateTime 2022/5/28
 */
public class Interceptor implements MethodInterceptor {
    @Override
    public Object intercept(Object obj, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {

        System.out.println("I am intercept begin");

        //Note: 此处一定要使用proxy的invokeSuper方法来调用目标类的方法
        methodProxy.invokeSuper(obj, args);

        System.out.println("I am intercept end");

        return null;
    }
}
